use "d:/Users/Andrey/Dropbox/data/fcpa/replication/firm level final.dta", clear
cd d:/Users/Andrey/Dropbox/data/fcpa/replication

log using firmlevel, text replace
*** Figure 1 ***
preserve

keep year FirmName
duplicates drop
drop if FirmName ==""

bysort year: gen totcase = _N

twoway line totcase year, scheme(s2mono) graphregion(fcolor(white)) xti(Year) yti(FCPA Enforcement Actions)

restore

*** Figure 3
hist sanctions2, scheme(s2mono) graphregion(fcolor(white)) xti(Sanctions (in Millions of $)) percent

*** Figure 4
bysort year: egen msanctions = mean(sanctions2)
twoway line msanctions year || lpoly msanctions year, bw(5) scheme(s2mono) graphregion(fcolor(white)) legend( lab(1 "Sanctions") lab(2 "Trend")) xti(Year) yti(Average Sanctions (in Millions of $))

*** Table 3 ****

reg lsanction lbribe lemployees  firmhomeUShome firmhomeUShost lgdppchome lgdppchost tradehost cpihost usfirm  polityhome polityhost count lusfdi  i.year , robust cluster(sname)
		estimates store m1

reg lsanction lbribe lemployees allyUShome allyUShost lgdppchome lgdppchost tradehost cpihost usfirm  polityhome polityhost   count lusfdi i.year , robust  cluster(sname)
		estimates store m2		

reg lsanction lbribe lemployees  leconaidUShome leconaidUShost lgdppchome lgdppchost tradehost cpihost usfirm  polityhome polityhost  count lusfdi  i.year , robust cluster(sname)
		estimates store m3
		
reg lsanction lbribe lemployees lmilaidUShome lmilaidUShost lgdppchome lgdppchost tradehost cpihost usfirm  polityhome polityhost  count  lusfdi  i.year , robust cluster(sname)
		estimates store m4

reg lsanction lbribe lemployees  armsUShome armsUShost lgdppchome lgdppchost tradehost cpihost usfirm  polityhome polityhost  count lusfdi i.year, robust cluster(sname)
		estimates store m5
		
mi set flong
mi xtset, clear
mi stset, clear


mi register imputed lbribe lemployees 

mi impute chain (truncreg,ll(0)) lbribe lemployees  = cpihost cpihome lgdppchome lgdppchost tradehome tradehost count i.year i.sectorid usfirm lsanction polityhost, add(20) force rseed(1562)

*** Table 4 ***
mi estimate, post: reg lsanction lbribe lemployees firmhomeUShome firmhomeUShost lgdppchome lgdppchost tradehost cpihost usfirm polityhome polityhost  lusfdi count i.year, robust  cluster(sname)
		estimates store m6

mi estimate, post: reg lsanction lbribe lemployees allyUShome allyUShost lgdppchome lgdppchost tradehost cpihost  usfirm polityhome polityhost  lusfdi count i.year, robust  cluster(sname)
		estimates store m7

mi estimate, post: reg lsanction lbribe lemployees leconaidUShome leconaidUShost lgdppchome lgdppchost tradehost cpihost usfirm polityhome polityhost  lusfdi count i.year , robust  cluster(sname)
		estimates store m8

mi estimate, post: reg lsanction lbribe lemployees lmilaidUShome lmilaidUShost lgdppchome lgdppchost tradehost cpihost usfirm  polityhome polityhost  lusfdi count i.year , robust  cluster(sname)
		estimates store m9

mi estimate, post: reg lsanction lbribe lemployees armsUShome armsUShost lgdppchome lgdppchost tradehost cpihost usfirm polityhome polityhost   lusfdi count i.year, robust  cluster(sname)
		estimates store m10
		
log close
